package com.akuma.redmine.service.impl;

import com.akuma.common.util.JsonUtils;
import com.akuma.redmine.entity.ProjectQuery;
import com.akuma.redmine.entity.StatusQuery;
import com.akuma.redmine.entity.StatusesQuery;
import com.akuma.redmine.exception.RedMineException;
import com.akuma.redmine.service.IIssueStatusService;
import com.akuma.redmine.util.RedMineHttpRequest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by akuma on 2016/10/13.
 *
 * @author akuma
 */
public class IssueStatusServiceImpl implements IIssueStatusService {
    public List<StatusQuery> findAll() {
        Map<String, String> params = new HashMap<String, String>();
        String s = null;
        try {
            s = RedMineHttpRequest.adminGet(params, "issue_statuses.json");
        } catch (Exception e) {
            RedMineException.throwException(e);
        }
        StatusesQuery statusesQuery = JsonUtils.readValue(s, StatusesQuery.class);
        if (statusesQuery != null) {
            return statusesQuery.getIssue_statuses();
        }
        return null;
    }
}
